<!doctype html>
<!--
 Copyright 2021 Google LLC

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<html>
<head>
  <title>Datastore and Firebase Auth Example</title>
  <script src="{{ url_for('static', filename='script.js') }}"></script>
  <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
  <script src="https://www.gstatic.com/firebasejs/9.13.0/firebase-app-compat.js"></script>
  <script src="https://www.gstatic.com/firebasejs/9.13.0/firebase-auth-compat.js"></script>
  <!-- [START gae_python38_auth_include_firebaseui] -->
  <script src="https://www.gstatic.com/firebasejs/ui/6.0.1/firebase-ui-auth.js"></script>
  <link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/6.0.1/firebase-ui-auth.css" />
  <!-- [END gae_python38_auth_include_firebaseui] -->
  <script>
    // TODO(DEVELOPER): Paste your firebaseConfig{} snippet here. Follow these instructions to
    // find your config object: https://support.google.com/firebase/answer/7015592#web
    firebase.initializeApp(firebaseConfig);

    if (typeof firebase === 'undefined') {
      const msg = "Please provide your Firebase configuration details. See instructions in templates/index.html.";
      console.log(msg);
      alert(msg);
    }
  </script>
</head>
<body>

<h1>Datastore and Firebase Auth Example</h1>
<!-- [START gae_python38_auth_firebase_html] -->
<div id="firebaseui-auth-container"></div>

<button id="sign-out" hidden=true>Sign Out</button>

<div id="login-info" hidden=true>
  <h2>Login info:</h2>
  {% if user_data %}
    <dl>
      <dt>Name</dt><dd>{{ user_data['name'] }}</dd>
      <dt>Email</dt><dd>{{ user_data['email'] }}</dd>
      <dt>Last 10 visits</dt><dd>
	{% for time in times %}
          <p>{{ time['timestamp'] }}</p>
        {% endfor %} </dd>
    </dl>
  {% elif error_message %}
    <p>Error: {{ error_message }}</p>
  {% endif %}
</div>
<!-- [END gae_python38_auth_firebase_html] -->
</body>
</html>
